﻿using System.Web;

namespace TweetSayingsLibrary.App.Entity
{
    public class QueryString
    {
        public static string String(string name)
        {
            return HttpContext.Current.Request.QueryString[name];
        }

        public static string String(string name, string defaultString)
        {
            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString[name]))
                return HttpContext.Current.Request.QueryString[name];

            return defaultString;
        }

        public static int Int(string name, int defaultValue)
        {
            int i;
            if (int.TryParse(HttpContext.Current.Request.QueryString[name], out i) == false)
                i = defaultValue;

            return i;
        }

        public static long Long(string name, long defaultValue)
        {
            long i;
            if (long.TryParse(HttpContext.Current.Request.QueryString[name], out i) == false)
                i = defaultValue;

            return i;
        }
    }
}
